﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BusinessService;

namespace BusinessLogic
{
   public class VwManager
    {
       public DataTable GetAllSheet()
       {
           var sql = "select * from vw_mysheet";
           return SqlHelper.ExecuteDataTable(sql);
       }

       public DataTable GetSheetsByRepairerId(string repairerId)
       {
           var sql = "select * from vw_mysheet where repId='"+repairerId+"'";
           return SqlHelper.ExecuteDataTable(sql);
       }

       public DataTable GetSheetsByApllierId(string apllierId)
       {
           var sql = "select * from vw_mysheet where applyId='" + apllierId + "'";
           return SqlHelper.ExecuteDataTable(sql);
       }

       public DataTable GetSheetHistoryByworkorder(string workorder)
       {
           var sql = "select * from vw_sheethistory where wordorderid='" + workorder+"'";
           return SqlHelper.ExecuteDataTable(sql);
       }

       public DataRow GetOneByOrder(string order)
       {
           var sql = "select top 1 * from vw_mysheet where WordOrderId='" + order+"'";
           var result = SqlHelper.ExecuteDataTable(sql);
           if (result.Rows.Count > 0)
           {
               return result.Rows[0];
           }
           else
               return null;
       }

    }
}
